package com.example.service.admin;

import com.example.entity.Course;
import com.example.entity.DTO.CourseDetailDTO;
import com.example.exception.CustomException;
import com.example.mapper.CourseMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminCourseService {
    @Resource
    private CourseMapper courseMapper;

    public List<CourseDetailDTO> selectAllCourse(String courseName, String teacherName, String deptName) {
        return courseMapper.selectAllCourseByNameAndTeacherNameAndDeptName(courseName, teacherName, deptName);
    }

    public void addCourse(Course course) {
        course.setSelectCount(0);
        courseMapper.insert(course);
    }

    public Course selectByName(String name) {
        return courseMapper.selectByName(name);
    }

    public void updateCourse(Course course) {
        courseMapper.updateById(course);
    }

    public void deleteCourse(Integer id) {
        courseMapper.deleteById(id);
    }
}
